#include "particlecompwidget.h"

ParticleCompWidget::ParticleCompWidget(AED_ParticleComp *comp, QWidget *parent) :
    QWidget(parent)
{
    m_comp = comp;

    QVBoxLayout *layout = new QVBoxLayout;
    this->setLayout(layout);

    group = new QGroupBox("Enable");
    layout->addWidget(group);
    group->setCheckable(true);

    QVBoxLayout *main_layout = new QVBoxLayout; // La layout principal
    group->setLayout(main_layout);

    QLabel *info = new QLabel("By enabling this component the entity will act as a particle, therefore being able to be used by particle systems.\n\nParticles are recommended to have only a Particle component and a Render Component to have an optimal performance.");
    info->setWordWrap(true);
    main_layout->addWidget(info);

    connect(group, SIGNAL(toggled(bool)),
                this,SLOT(SetEnabled(bool)));
}

void ParticleCompWidget::setComp(AED_ParticleComp *comp){
    m_comp = comp;
    if(!m_comp){
        group->setEnabled(false);
    }else{
        group->setEnabled(true);
        group->setChecked(comp->IsEnabled());
    }
}

void ParticleCompWidget::SetEnabled(bool enabled){

    m_comp->SetEnabled(enabled);
}
